
<%
	long wn_id = task.doTask();
	Record ref = task.getWN_Ref();
%>

<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">
	var wn_type = "<%=wn_type%>";
	getObj("main_window").width = "800";
</script>
<form method="POST" name="formMain" action="" onSubmit="">				  
	<table width="100%"  border="0" class="style2">
		<tr>
			<td colspan="3"><img src="images/weighing.jpg" width="200" height="20"></td>
		</tr>
          <tr>
            <td width="16%" valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="style2">
  <tr bgcolor="#EEEEEE">
  	<td align="center"><strong>WN Ref </strong></td>
  </tr>			
  <tr>
    <td><select name="wn_id" size=16 class="style2" id="wn_id" style="width:100%;" onChange="doPost();">
              <%task.getResponse().setOption(task.getWN_List());%>
              <%task.getResponse().setSelected("wn_id", wn_id);%>
            </select></td>
  </tr>
  <tr>
    <td><img src="images/new.gif" border="0" width="15" height="15" onClick="new_WN('<%=task.getNew_WN()%>')">&nbsp;<img src="images/delete.gif" width="15" height="15" border="0" onClick="delete_WN()"></td>
    </tr>
</table>
</td>
            <td colspan="2" valign="top"><table width="100%"  border="1" cellspacing="0" cellpadding="0">
	  <tr>
    <td><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
              <tr>
                <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
				  <tr>
				  	<td><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
                          <tr bgcolor="#EEEEEE" align="center" class="style2" style="font-weight:bold">
                            <td width="20%">Type</td>
                            <td width="20%">Contract Ref </td>
                            <td width="20%">Broker No </td>
                            <td width="20%">Supplier/Buyer</td>
                            <td width="20%">DI/SI Ref </td>
                          </tr>
                          <tr>
                            <td><select name="wn_type" id="wn_type" size=7 class="style11" style="width:100%;" onChange="doPost();">
                              <option value="I" selected>Import</option>
                              <option value="N">In-Process</option>
                              <option value="X">Ex-Process</option>
                              <option value="E">Export</option>
                              <%task.getResponse().setSelected("wn_type",task.getRequest().getStringValue("wn_type","I"));%>
                            </select></td>
                            <td><select name="contract_id" size="7" id="contract_id" onChange="doPost();" class="style11" style="width:100%;">
                              <option value="0" selected>All</option>
                              <%task.getResponse().setOption(task.getContract_List());%>
                              <%task.getResponse().setSelected("contract_id");%>
                            </select></td>
                            <td><select name="broker_id" size="7" id="broker_id" onChange="doPost();" class="style11" style="width:100%;">
                              <option value="0" selected>All</option>
                              <%task.getResponse().setOption(task.getBroker_List());%>
                              <%task.getResponse().setSelected("broker_id");%>
                            </select></td>
                            <td><select name="supplier_buyer_id" id="supplier_buyer_id" size=7 class="style11" style="width:100%;" onChange="doPost();">
                              <option value="0" selected>All</option>
                              <%task.getResponse().setOption(task.getCompanyList("supplier,buyer"));%>
                              <%task.getResponse().setSelected("supplier_buyer_id");%>
                            </select></td>
                            <td><select name="inst_id" id="inst_id" size=7 class="style11" style="width:100%;" onChange="doPost();">
                              <option value="0" selected>All</option>
                              <%task.getResponse().setOption(task.getInst_List());%>
                              <%task.getResponse().setSelected("inst_id");%>
                            </select></td>
                          </tr>
                        </table></td>
				  </tr>
                  <tr>
                    <td><table width="100%"  border="0" cellpadding="1" cellspacing="1" class="style2">
                      <tr>
                        <td width="20%">&nbsp;</td>
                        <td width="29%">&nbsp;</td>
                        <td width="19%">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td align="right">Contract Ref &nbsp;</td>
                        <td><strong><%=ref.getString("ct_ref_number")%> (<%=ref.getString("contract_no")%>)</strong></td>
                        <td align="right">Origin &nbsp;</td>
                        <td><strong><%=ref.getString("origin")%></strong></td>
                      </tr>
                      <tr>
                        <td align="right">Supplier &nbsp;</td>
                        <td><strong><%=ref.getString("supplier")%></strong></td>
                        <td align="right">Quality &nbsp;</td>
                        <td><strong><%=ref.getString("quality")%></strong></td>
                      </tr>
                      <tr>
                        <td align="right">DI Ref &nbsp;</td>
                        <td><strong><%=ref.getString("di_ref_number")%></strong></td>
                        <td align="right">Grade &nbsp;</td>
                        <td><strong><%=ref.getString("grade")%></strong></td>
                      </tr>
                      <tr>
                        <td align="right">Quantity&nbsp;</td>
                        <td colspan="2"><strong><%=ref.getFloatValue("di_tons")%> Mts / <%=ref.getString("di_no_of_bags")%> <%=ref.getString("packing")%>s</strong></td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td align="right">&nbsp;</td>
                        <td colspan="2">&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td><strong>Weight Note </strong></td>
                        <td colspan="3"><table id="wn_export_" width="100%"  border="0" cellpadding="0" cellspacing="0" class="style2">
                          <tr>
                            <td align="right">Container No &nbsp;</td>
                            <td><input type="text" name="container_no" id="container_no" class="style2" style="width:100px;" value="<%=wn_type.equals("E")?ref.getString("container_no"):""%>"></th>
                            <td align="right">Seal No &nbsp;</td>
                            <td><input type="text" name="seal_no"      id="seal_no"      class="style2" style="width:100px;" value="<%=wn_type.equals("E")?ref.getString("seal_no"):""%>"></th>
                            <td align="right">ICO No &nbsp;</td>
                            <td><input type="text" name="ico_no"       id="ico_no"       lass="style2"  style="width:100px;" value="<%=wn_type.equals("E")?ref.getString("ico_no"):""%>"></th>
                          </tr>
                        </table></td>
                        </tr>
                      <tr>
                        <td colspan="4"><table width="100%"  border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%"  border="0" cellpadding="0" cellspacing="1" class="style2">
                          <tr align="center" bgcolor="#EEEEEE" style="font-weight:bold">
                            <td width="5%" rowspan="2">ID</td>
                            <td width="20%" rowspan="2">WN Ref </td>
                            <td width="12%" rowspan="2">Date</td>
                            <td width="11%" rowspan="2">Time</td>
                            <td width="23%" rowspan="2">Packing</td>
                            <td width="7%" rowspan="2">Num</td>
                            <td colspan="3">Tons</td>
                            </tr>
                          <tr align="center" bgcolor="#EEEEEE">
                            <td width="8%">Gross</td>
                            <td width="7%">Tare</td>
                            <td width="7%">Net</td>
                          </tr>
                          <tr>
                            <td align="right"><%=ref.getInt("id")%> &nbsp;</td>
                            <td><%=ref.getString("ref_number")%></td>
                            <td align="center"><%=ref.getDate("date")%></td>
                            <td align="center"><%=ref.getTime("time")%></td>
                            <td><%=ref.getString("packing")%></td>
                            <td align="center"><input type="text" name="no_of_bags" id="no_of_bags"     class="style2" style="width:60px; text-align:right" value="<%=ref.getInt("no_of_bags")%>" readonly=""></td>
                            <td align="center"><input type="text" name="gross_weight" id="gross_weight" class="style2" style="width:60px; text-align:right" value="<%=ref.getFloat("gross_weight")%>" readonly=""></td>
                            <td align="center"><input type="text" name="tare_weight" id="tare_weight"   class="style2" style="width:60px; text-align:right" value="<%=ref.getFloat("tare_weight")%>" readonly=""></td>
                            <td align="center"><input type="text" name="net_weight" id="net_weight"     class="style2" style="width:60px; text-align:right" value="<%=ref.getFloat("net_weight")%>" readonly=""></td>
                          </tr>
                        </table></td>
  </tr>
</table>
</td>
                      </tr>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
			  <tr>
			    <td>&nbsp;</td>
		      </tr>
			  <tr>
			    <td><strong>WNR Ref </strong></td>
			  </tr>
              <tr>
                <td><table width="100%"  border="1" cellspacing="0" cellpadding="0">
  <tr>
    <td><table width="100%"  border="0" cellpadding="0" cellspacing="1" class="style2">
                  <tr style="font-weight:bold" bgcolor="#EEEEEE" align="center">
                    <td width="21" rowspan="2">No</td>
                    <td width="120" rowspan="2">WNR Ref </td>
                    <td width="95" rowspan="2">Date</td>
                    <td width="96" rowspan="2">Time</td>
                    <td width="192" rowspan="2">Packing</td>
                    <td width="60" rowspan="2">Num</td>
                    <td colspan="3">Tons</td>
                    <td width="18" rowspan="2">Del</td>
                    <td width="21" rowspan="2">Sav</td>
                  </tr>
                  <tr style="font-weight:bold" bgcolor="#EEEEEE" align="center">
                    <td width="60">Gross</td>
                    <td width="60">Tare</td>
                    <td width="60">Net</td>
                    </tr>
<%
	Record rc = new Record(task.wnr.getWNR_Detail());
	rc.beforeFirst();
	int no = 1;
	while (rc.next()) {
%>				  
		  <input type="hidden" name="wnr_id_<%=no%>"  id="wnr_id_<%=no%>"  value="<%=rc.getLongValue("id")%>">
                  <tr class="style11" onClick="highlightOn(this);" onDblClick="doLink('traffic.di.jsp?view=1&di_id=<%=rc.getInt("id")%>')">
                    <td align="center" bgcolor="#EEEEEE"><%=rc.getRow()%></td>
                    <td><input type="text" name="wnr_ref_number_<%=no%>" id="wnr_ref_number_<%=no%>" class="style2" style="width:130px;" value="<%=rc.getString("ref_number")%>"></td>
                    <td align="center"><input type="text" name="wnr_date_<%=no%>" id="wnr_date_<%=no%>" class="style2" style="width:60px; text-align:center" value="<%=rc.getDate("date")%>"></td>
                    <td align="center"><input type="text" name="wnr_time_<%=no%>" id="wnr_time_<%=no%>" class="style2" style="width:60px; text-align:center" value="<%=rc.getTime("time")%>"></td>
                    <td><%=ref.getString("packing")%></td>
                    <td align="center"><input type="text" name="wnr_no_of_bags_<%=no%>"   id="wnr_no_of_bags_<%=no%>"   class="style2" style="width:60px; text-align:right" value="<%=rc.getInt("no_of_bags")%>"     onChange="no_of_bags_Changed('wnr',<%=no%>,this.value)"></td>
                    <td align="center"><input type="text" name="wnr_gross_weight_<%=no%>" id="wnr_gross_weight_<%=no%>" class="style2" style="width:60px; text-align:right" value="<%=rc.getFloat("gross_weight")%>" onChange="gross_Changed('wnr',<%=no%>,this.value)"></td>
                    <td align="center"><input type="text" name="wnr_tare_weight_<%=no%>"  id="wnr_tare_weight_<%=no%>"  class="style2" style="width:60px; text-align:right" value="<%=rc.getFloat("tare_weight")%>"  onChange="tare_Changed('wnr',<%=no%>,this.value)"></td>
                    <td align="center"><input type="text" name="wnr_net_weight_<%=no%>"   id="wnr_net_weight_<%=no%>"   class="style2" style="width:60px; text-align:right" value="<%=rc.getFloat("net_weight")%>"   readonly=""></td>
                    <td align="center"><img src="../shared/images/delete.gif" width="15" height="15" onClick="delete_WNR(<%=no%>)"></td>
                    <td align="center"><img src="../shared/images/update.gif" width="15" height="15" onClick="save_WNR(<%=no%>)"></td>
                  </tr>
<%
		no++;
	}
%>				  
		  <input type="hidden" name="wnr_id_<%=no%>"  id="wnr_id_<%=no%>"  value="0">
                  <tr id="wnr_<%=no%>" class="style2" style="display:none">
                    <td align="center"bgcolor="#EEEEEE">&nbsp;</td>
                    <td><input type="text" name="wnr_ref_number_<%=no%>" id="wnr_ref_number_<%=no%>" class="style2" style="width:130px;" value="<%=task.wnr.getNew_WNR()%>"></td>
                    <td align="center"><input type="text" name="wnr_date_<%=no%>" id="wnr_date_<%=no%>" class="style2" style="width:60px; text-align:center" value=""></td>
                    <td align="center"><input type="text" name="wnr_time_<%=no%>" id="wnr_time_<%=no%>" class="style2" style="width:60px; text-align:center" value=""></td>
                    <td><%=ref.getString("packing")%></td>
                    <td align="center"><input type="text" name="wnr_no_of_bags_<%=no%>"   id="wnr_no_of_bags_<%=no%>"   class="style2" style="width:60px; text-align:right" onChange="no_of_bags_Changed('wnr',<%=no%>,this.value)"></td>
                    <td align="center"><input type="text" name="wnr_gross_weight_<%=no%>" id="wnr_gross_weight_<%=no%>" class="style2" style="width:60px; text-align:right" onChange="gross_Changed('wnr',<%=no%>,this.value)"></td>
                    <td align="center"><input type="text" name="wnr_tare_weight_<%=no%>"  id="wnr_tare_weight_<%=no%>"  class="style2" style="width:60px; text-align:right" onChange="tare_Changed('wnr',<%=no%>,this.value)"></td>
                    <td align="center"><input type="text" name="wnr_net_weight_<%=no%>"   id="wnr_net_weight_<%=no%>"   class="style2" style="width:60px; text-align:right" readonly=""></td>
                    <td align="center"><img src="../shared/images/delete.gif" width="15" height="15" onClick="delete_WNR(<%=no%>)"></td>
                    <td align="center"><img src="../shared/images/update.gif" width="15" height="15" onClick="save_WNR(<%=no%>)"></td>
                  </tr>
                  <tr class="style2">
                    <td align="center" height="20"><img src="../shared/images/new.gif" width="15" height="15" title="Create New DI" onClick="new_WNR(<%=no%>)"></td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                    <td align="right">&nbsp;</td>
                  </tr>
                </table></td>
  </tr>
</table>
</td>
              </tr>
			  <tr>
			  	<td><input type="hidden" name="no"  id="no"  value="0"></td>
			  </tr>
            </table></td>
  </tr>
</table>
</td>
          </tr>
		  <tr id="di_list_view">
			  <td colspan="3"  valign="top">
		  
			  </td>
		  </tr>
		  <tr style="display:">
		  	<td>&nbsp;</td>
		  	<td width="38%"><img src="../shared/images/update.gif" width="15" height="15" onClick="save_WN()"></td>
		    <td width="46%" align="right"><img src="../shared/images/listview.jpg" width="55" height="18" onClick="setValue('view',0);doPost()"></td>
		  </tr>
  </table>
	<input type="hidden" name="uid"  id="uid"  value="<%=user.getuid()%>">
	<input type="hidden" name="task_id"  id="task_id"  value="0">
	<input type="hidden" name="view" id="view" value="<%=task.getRequest().getIntValue("view")%>">	
<!--	<input type="hidden" name="inst_id"  id="inst_id"  value="<%//=task.getRequest().getIntValue("inst_id")%>"> -->
</form>

<script language="javascript">
	if (wn_type == "E") show("wn_export_");
	else hide("wn_export_");
	
	hide("sub_menu_3");
	setCbx(getObj("status_"), <%=ref.getIntValue("status")%>);

	if (getValue("wn_id") == 0) hide("update_btn");
	if (<%=wn_id == -1%>) {	
		var idx = addNewListItem(document.formMain.wn_id,"<%=task.getNew_WN()%>");
		setText("ref_number_",getSelectedText("wn_id"));
	}

</script>

